know which side (one's) bread is buttered

Translations
savoir où est son intérêt
Definitions
To be aware of where one's best interests lie or to know who or what provides one with advantages, benefits, or support, and to act accordingly.